﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ggdll.GGMessages.Incoming
{
    class GGMessageNotifyReply
    {

        public List<GGContacts.GGContactState> GGcontactstates = new List<GGContacts.GGContactState>();

        public GGMessageNotifyReply(byte[] data)
        {
            int message_size=BitConverter.ToInt32(data,4);
            int message_pos=8;

            while(message_pos<message_size)
            {
                GGContacts.GGContactState ggcs = new GGContacts.GGContactState();

                ggcs.uin = BitConverter.ToInt32(data, message_pos);
                message_pos+=4;
                ggcs.status = BitConverter.ToInt32(data, message_pos);
                message_pos+=4;
                ggcs.features = BitConverter.ToInt32(data, message_pos);
                message_pos+=4;
                ggcs.remote_ip = BitConverter.ToInt32(data, message_pos);
                message_pos+=4;
                ggcs.remote_port = BitConverter.ToInt16(data, message_pos);
                message_pos+=2;
                ggcs.image_size = data[message_pos];
                message_pos+=2;
                ggcs.flags = BitConverter.ToInt32(data, message_pos);
                message_pos+=4;
                ggcs.description_size = BitConverter.ToInt32(data, message_pos);
                message_pos+=4;
                ggcs.description = new string(StaticVars.enc.GetChars(data, message_pos, ggcs.description_size));
                message_pos+=ggcs.description_size;
                GGcontactstates.Add(ggcs);
            }

        }
    }
}
